<%-- 
    Document   : ReturnBook
    Created on : Mar 28, 2014, 2:28:29 PM
    Author     : mishra
--%>

<%
      try {
        if (session.getAttribute("uid") != null) {
         if (session.getAttribute("Return_Book").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<!DOCTYPE html>
<html>
    <head>
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <script src="../../ajax/ajax.js"></script>
        <script>
            function getRetDetial(bookno)
            { 
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                { 
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
                        
                        if(xmlhttp.responseText==2){
                            document.getElementById('hid').innerHTML='<div class="alert alert-error, alert-block" id="hid"><a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a><h4 class="alert-heading" id="msg">Fail</h4>Book is Damage/Lost!!</div>';
                            document.getElementById('subm').disabled=true;
                        }
                        if(xmlhttp.responseText==0){
                            document.getElementById('hid').innerHTML='<div class="alert alert-info alert-block" id="hid"><a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a><h4 class="alert-heading" id="msg">Fail</h4>Book is Not Issued!!</div>';
                             document.getElementById('subm').disabled=true;
                        }
                        else{
                        var total=xmlhttp.responseText.split("--");
                            document.getElementById('nocode').value=total[1];
                            document.getElementById('btransno').value=total[4];
                            document.getElementById('esname').value=total[15];
                            document.getElementById('idate').value=total[7];
                            document.getElementById('rdate').value=total[8];
                            document.getElementById('userType').value=total[9];
                            document.getElementById('bname').value=total[10];
                            document.getElementById('tdays').value=total[11];
                            document.getElementById('ldays').value=total[12];
                            document.getElementById('fine').value=total[13];
                            document.getElementById('bprice').value=total[14];
                        }
                        
                    }
                }
                xmlhttp.open("POST","/RIT/getReturnDetials?bookno="+bookno,false);
                xmlhttp.send();
            }
            
            function getDesc(id){
                if( document.getElementById(id).checked){
                    document.getElementById('desc').readOnly=false;
                    document.getElementById('fine').value=parseInt(document.getElementById('fine').value)+parseInt(document.getElementById('bprice').value);
                    document.getElementById('check').value='2';
                }else{
                    document.getElementById('desc').readOnly=true;
                    document.getElementById('desc').value="";
                    document.getElementById('fine').value=parseInt(document.getElementById('fine').value)-parseInt(document.getElementById('bprice').value);
                    document.getElementById('check').value='1';
                }
            }
            function getEnable(){
                document.getElementById('fine').readOnly=false;
            }
            function hidediv(){
                document.getElementById('hid').style.display='none';
            }
        </script>

    </head>
    <body>

        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Services/Library/librarysidenav.jsp" %>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-success alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>

                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div id="hid">
                        
                    </div>
                    
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>Book Return</h3>
                                    <!--<a href="ReturnBook.jsp">
                                        <button style="float: right" class="btn btn-success ">View Book Return</button>
                                    </a>-->
                                </div>
                                <div class="box-content box-nomargin">
                                    <%if (session.getAttribute("msg") != null) {%>
                                    <div class="modal" id="myModal">
                                        <div class="modal-header">
                                            <button type="button" class="close" onclick="document.getElementById('myModal').className='modal hide'"><img src="/RIT/img/mclose.png"></button>
                                            <h3><%=session.getAttribute("status")%></h3>
                                        </div>
                                        <div class="modal-body">
                                            <p><%=session.getAttribute("msg")%></p>
                                        </div>
                                        <div class="modal-footer">
                                            <a href="#" class="btn btn-primary" onclick="document.getElementById('myModal').className='modal hide'"> Ok </a>
                                        </div>
                                    </div>
                                    <%session.removeAttribute("msg");
                                        session.removeAttribute("status");%>
                                    <%}%>
                                    <form action="/RIT/BookReturn" method="post" class='validate form-horizontal'>
                                        <div class="box-content">
                                            <!---Form Start....-->

                                            <div id="lside" style="float: left; margin-top: 10px;">

                                                <div class="control-group">
                                                    <label for="bno" class="control-label">Book No.</label>
                                                    <div class="controls">
                                                        <input type="text" name="bno" id="bno" class='required' onblur="checkBookReturn(this.value)">
                                                        <input type="hidden" name="btransno" id="btransno" class='required'>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="bname" class="control-label">Admission No./ Employee Code</label>
                                                    <div class="controls">
                                                        <input type="text" name="nocode" id="nocode" class='required' readonly>
                                                        <input type="hidden" name="userType" id="userType">
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="idate" class="control-label">Issue Date</label>
                                                    <div class="controls">
                                                        <input type="text" name="idate" id="idate" readonly>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="tdays" class="control-label">Total Days</label>
                                                    <div class="controls">
                                                        <input type="text" name="tdays" id="tdays" readonly>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="fine" class="control-label">Fine Amount(if any)</label>
                                                    <div class="controls">
                                                        <input type="text" name="fine" id="fine" readonly>
                                                        <input type="hidden" name="bprice" id="bprice">
                                                        <a style="cursor: -webkit-grab"><img alt="" class="ico-prev" id="edit" name="edit"  onclick="getEnable(this.id)" src="/RIT/img/icons/essen/16/pencil.png"></a>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="lost" class="control-label"><b>Book Damage/Lost?</b></label>
                                                    <div class="controls">
                                                        <input type="checkbox" name="lost" id="lost " value="" readonly onclick="getDesc(this.id)">
                                                        <input type="hidden" name="check" id="check" value="1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="rside" style="float: right; margin-right: 120px; margin-top: 10px">
                                                <div class="control-group">
                                                    <label for="price" class="control-label"></label>
                                                    <div class="controls">
                                                        <div class="input-append">
                                                            <center>
                                                                <button type="button" class="btn btn-info" id="searchbutton" style="padding-top: 5px; padding-bottom: 5px; padding-left: 10px; padding-right: 10px;" onclick="getRetDetial(document.getElementById('bno').value,document.getElementById(''))">Search Book</button>
                                                            </center>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="price" class="control-label">Employee/ Student Name</label>
                                                    <div class="controls">
                                                        <div class="input-append">
                                                            <input type="text" name="esname" id="esname" class='{required:true}' readonly="">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="rdate" class="control-label">Returning Date</label>
                                                    <div class="controls">
                                                        <input type="text" name="rdate" id="rdate" readonly>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="ldays" class="control-label">Late Days</label>
                                                    <div class="controls">
                                                        <input type="text" name="ldays" id="ldays" readonly>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label for="fine" class="control-label">Book Name</label>
                                                    <div class="controls">
                                                        <div class="input-append">
                                                            <input type="text" name="bname" id="bname"  class='{required:true}' readonly="">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="control-group" id="de">
                                                    <label for="desc" class="control-label">Description</label>
                                                    <div class="controls">
                                                        <div class="input-append">
                                                            <textarea name="desc" id="desc" readonly></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-actions">
                                            <input type="submit" id="subm" name="subm" class='btn btn-primary'>
                                        </div>
                                    </form>
                                    <!---Form Ends....-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.uniform.min.js"></script>
        <script src="/RIT/js/bootstrap.timepicker.js"></script>
        <script src="/RIT/js/bootstrap.datepicker.js"></script>
        <script src="/RIT/js/chosen.jquery.min.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/plupload/plupload.full.js"></script>
        <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
        <script src="/RIT/js/jquery.cleditor.min.js"></script>
        <script src="/RIT/js/jquery.inputmask.min.js"></script>
        <script src="/RIT/js/jquery.tagsinput.min.js"></script>
        <script src="/RIT/js/jquery.mousewheel.js"></script>
        <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
        <script src="/RIT/js/ui.spinner.js"></script>
        <script src="/RIT/js/jquery.jgrowl_minimized.js"></script>
        <script src="/RIT/js/jquery.form.js"></script>
        <script src="/RIT/js/jquery.validate.min.js"></script>
        <script src="/RIT/js/bbq.js"></script>
        <script src="/RIT/js/jquery-ui-1.8.22.custom.min.js"></script>
        <script src="/RIT/js/jquery.form.wizard-min.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.metadata.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="/RIT/js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
    </body>
</html>
<%
     } else { out.println("<script>alert('" + session.getAttribute("Enquiry")+ "')</script>");
     
%>
<script type="text/javascript">
      alert("You Are Not Authorised");
    window.history.back();
</script>
<%
          }
    } else {
      request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
    request.setAttribute("value", "0");
    getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
    } catch (Exception e) {
      request.setAttribute("msg", "Please Contact to System Administrator!");
     request.setAttribute("value", "0");
    getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }

%>